home *** CD-ROM | disk | FTP | other *** search
/ HAKERIS 11 / HAKERIS 11.ISO / linux / system / LinuxConsole 0.4 / linuxconsole0.4install-en.iso / linuxconsole0.4.lcm / etc / hotplug / usb / usbcam < prev   
Encoding:
Text File  |  2004-03-26  |  1.9 KB  |  64 lines

  1. #!/bin/bash
  2. # $Id: usbcam.console,v 1.4 2002/09/12 16:50:18 hun Exp $
  3. #
  4. # /etc/hotplug/usb/usbcam
  5. #
  6. # Sets up newly plugged in USB camera so that the user who owns
  7. # the console according to pam_console can access it from user space
  8. #
  9. # Note that for this script to work, you'll need all of the following:
  10. # a) a line in the file /etc/hotplug/usermap that corresponds to the 
  11. #    camera you are using. You can get the correct lines for all cameras 
  12. #    supported by libgphoto2 by running "print-usb-usermap".
  13. # b) a setup using pam_console creates the respective lock files
  14. #    containing the name of the respective user. You can check for that
  15. #    by executing "echo `cat /var/{run,lock}/console.lock`" and 
  16. #    verifying the appropriate user is mentioned somewhere there.
  17. # c) a Linux kernel supporting hotplug and usbdevfs
  18. # d) the hotplug package (http://linux-hotplug.sourceforge.net/)
  19. #
  20. # In the usermap file, the first field "usb module" should be named 
  21. # "usbcam" like this script.
  22.  
  23. if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]
  24. then
  25.     # New code, using lock files instead of copying /dev/console permissions
  26.     # This also works with non-gdm logins (e.g. on a virtual terminal)
  27.     # Idea and code from Nalin Dahyabhai <nalin@redhat.com>
  28.     if [ -f /var/run/console.lock ]
  29.     then
  30.         CONSOLEOWNER=`cat /var/run/console.lock`
  31.     elif [ -f /var/lock/console.lock ]
  32.     then
  33.         CONSOLEOWNER=`cat /var/lock/console.lock`
  34.     else
  35.         CONSOLEOWNER=
  36.     fi
  37.     if [ -n "$CONSOLEOWNER" ]
  38.     then
  39.         chmod 0000 "${DEVICE}"
  40.         chown "$CONSOLEOWNER" "${DEVICE}"
  41.         chmod 0600 "${DEVICE}"
  42.     fi
  43. fi
  44.  
  45. # Mandrake Linux specific part
  46.  
  47. SCRIPT=/etc/dynamic/scripts/camera.script
  48.  
  49. if [ -x $SCRIPT ]; then
  50.     if [ "${ACTION}" = "add" ]; then
  51.     $SCRIPT add "${DEVICE}"
  52.     if [ -n "$REMOVER" ]; then
  53.         cat > $REMOVER <<EOF
  54. #!/bin/sh
  55.  
  56. $SCRIPT del "${DEVICE}"
  57. EOF
  58.             chmod +x $REMOVER
  59.     fi
  60.     fi
  61. fi
  62.  
  63.